import fs  from "fs";


export default class Stratics {
    run(_path){
        let statics=new _Statics(_path);
        qguan("Statics",statics,null,'save');
    }
}


class _Statics{
    constructor(_path){
        this.staticPath=_path;
        let root =qguan("root");

        this.rootPath= root.rootPath;
    }

    run(req,res,url,type){
        try {
            if(fs.statSync(this.rootPath +"/"+this.staticPath+"/"+url.pathname).isFile()){
                let code=fs.readFileSync(this.rootPath +"/"+this.staticPath+"/"+url.pathname,'utf8');

                res.write(code)
                res.end();
            }

        }catch (e){
            console.error("路径不正确"+this.rootPath +"/"+this.staticPath+"/"+url.pathname)
           // console.error(e)
        }
    }

}